package com.leaf.spring.y201907.day12.zk;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

public class ZookeeperWatcher implements Watcher {
	
	private boolean isConnected = false;

	@Override
	public void process(WatchedEvent event) {

		System.out.println("receive event:" + event);
		if (Event.KeeperState.SyncConnected == event.getState()) {
			isConnected = true;
			System.out.println("连上了。。。");
		} else if (Event.EventType.NodeChildrenChanged == event.getType()) {
			System.out.println("获取子节点。。。"+event.getPath());
		}

	}

	public boolean isConnected() {
		return isConnected;
	}

}
